-
Notifications
You must be signed in to change notification settings - Fork 175
Handle String-like and IO-like objects for Ripper.sexp #3891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
eregon
commented
Jan 29, 2026
- RSpec relies on this in https://github.com/rspec/rspec/blob/rspec-support-v3.13.6/rspec-support/lib/rspec/support/source.rb#L57 which is given an RSpec::Support::EncodedString.
- CI failure caused by this on truffleruby: https://github.com/sporkmonger/addressable/actions/runs/21457707372/job/61802608154#step:7:14
5bbfbcf to
6e1d9e9
Compare
Earlopain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the rules are a bit more complex: https://github.com/ruby/ruby/blob/acc414572c213f2690eee56bac3d2355a24e5930/ext/ripper/ripper_init.c.tmpl#L357-L376
Do you want to implement those also? File should be easy at least.
I see. If you want to do it feel free to push to this branch, otherwise I can get to it tomorrow or so. |
|
Tomorrow is fine |
* RSpec relies on this in https://github.com/rspec/rspec/blob/rspec-support-v3.13.6/rspec-support/lib/rspec/support/source.rb#L57 which is given an RSpec::Support::EncodedString. * CI failure caused by this on truffleruby: https://github.com/sporkmonger/addressable/actions/runs/21457707372/job/61802608154#step:7:14
6e1d9e9 to
a83cb7b
Compare
|
Done, now it also handles IO object (= T_FILE) and |
| def initialize(source, filename = "(ripper)", lineno = 1) | ||
| @source = source | ||
| if source.is_a?(IO) | ||
| @source = source.read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be backed by Prism.parse_stream but since we need the whole source anyways I think this is fine. BTW, wouldn't work for the gets case since prism also expects eof? to be present
| end | ||
| else | ||
| @source = source.to_str | ||
| end |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.